#! /bin/bash
HIVE_HOME=/usr/bin/hive


${HIVE_HOME} -S -e "
--分区
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.created.files=150000;

==班级在读学生人数(维度表)
insert overwrite table zx_dwd.dim_class_studying_student_count partition(dt)
select
       id,
       school_id,
       subject_id,
       class_id,
       studying_student_count,
       studying_date,
       dt
from zx_ods.class_studying_student_count;

==班级课表(维度表)
insert overwrite table zx_dwd.dim_course_table_upload_detail partition(dt)
select
       id,
       base_id,
       class_id,
       class_date,
       content,
       teacher_id,
       teacher_name,
       job_number,
       classroom_id,
       classroom_name,
       is_outline,
       class_mode,
       is_stage_exam,
       is_pay,
       tutor_teacher_id,
       tutor_teacher_name,
       tutor_job_number,
       is_subsidy,
       answer_teacher_id,
       answer_teacher_name,
       answer_job_number,
       remark,
       create_time,
       dt
from zx_ods.course_table_upload_detail;


==班级作息时间表
insert overwrite table zx_dwd.dim_tbh_class_time_table partition(dt)
select
       id,
       class_id,
       morning_template_id,
       morning_begin_time,
       morning_end_time,
       afternoon_template_id,
       afternoon_begin_time,
       afternoon_end_time,
       evening_template_id,
       evening_begin_time,
       evening_end_time,
       use_begin_date,
       use_end_date,
       create_time,
       create_person,
       remark,
       dt
from zx_ods.tbh_class_time_table;

==学生请假申请表(事实表)
insert overwrite table zx_dwd.fact_student_leave_apply partition(dt)
select
       id,
       class_id,
       student_id,
       audit_state,
       audit_person,
       audit_time,
       audit_remark,
       leave_type,
       leave_reason,
       begin_time,
       begin_time_type,
       end_time,
       end_time_type,
       days,
       cancel_state,
       cancel_time,
       old_leave_id,
       leave_remark,
       valid_state,
       create_time,
       dt
from zx_ods.student_leave_apply;

==学生打卡记录表(事实表)
insert overwrite table zx_dwd.fact_tbh_student_signin_record partition(dt)
select
       id,
       normal_class_flag,
       time_table_id,
       class_id,
       student_id,
       signin_time,
       signin_date,
       inner_flag,
       signin_type,
       share_state,
       inner_ip,
       dt
from zx_ods.tbh_student_signin_record;